package mysgoog.gtp;

public class Color
{
    static final private int EMPTY_ID = 0, BLACK_ID = 1, WHITE_ID = 2;
    static final public Color EMPTY = new Color(EMPTY_ID), BLACK = new Color(BLACK_ID),
            WHITE = new Color(WHITE_ID);
    private int c;

    private Color(int c)
    {
        this.c = c;
    }
    public Color complement()
    {
        switch (c)
        {
            case EMPTY_ID :
                return EMPTY;
            case BLACK_ID :
                return WHITE;
            case WHITE_ID :
                return BLACK;
        }
        throw new Error("!!!");
    }
    public boolean isFilled()
    {
        return (c != EMPTY_ID);
    }
    public static Color parseColor(String s)
    {
        if (s.toLowerCase().charAt(0) == 'b')
            return BLACK;
        if (s.toLowerCase().charAt(0) == 'w')
            return WHITE;
        throw new Error("!!!");
    }
    public static Color[] getColors()
    {
        return new Color[]{BLACK, WHITE};
    }
    public String toString()
    {
        switch (this.c)
        {
            case EMPTY_ID :
                return "EMPTY";
            case BLACK_ID :
                return "BLACK";
            case WHITE_ID :
                return "WHITE";
        }
        throw new Error("!!!");
    }
}
